package itsm.isperp.workflow.cmd;

import itsm.isperp.workflow.graph.ActivitiHistoryGraphBuilder;
import itsm.isperp.workflow.graph.Graph;
import itsm.isperp.workflow.graph.Node;

import java.util.List;

import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 
 * 
 * 
 * @author lizx
 * @date 2015-2-3
 * @since 1.0
 * 
 */
public class FindUserTaskCmd implements Command<List<Node>> {

	private static Logger logger = LoggerFactory
			.getLogger(FindUserTaskCmd.class);

	String processInstanceId;

	public FindUserTaskCmd(String processInstanceId) {
		this.processInstanceId = processInstanceId;
	}

	@Override
	public List<Node> execute(CommandContext commandContext) {
		return findUserTask();
	}

	public List<Node> findUserTask() {

		Graph graph = new ActivitiHistoryGraphBuilder(processInstanceId)
				.build();

		return graph.getNodes();

	}

}
